<template>
    <div>
<h1>等级显示</h1>
<table class="table">
<thead>
    <tr>
        <td>等级id</td>
        <td>等级名称</td>
        <td>等级状态</td>
        <td>操作</td>
    </tr>
</thead>
<tbody>
    <tr v-for="a in da">
        <td>{{a.dId}}</td>
        <td>{{a.djName}}</td>
        <td>{{a.djState?"启用":"禁用"}}</td>
        <td>
            <input type="button" :value="a.djState==true?'禁用':'启用'" @click="gai(a.dId)">
        </td>
    </tr>
</tbody>
</table>
<a href="/adddj">等级录入</a>
    </div>
</template>




<script setup lang="ts">
import axios from 'axios';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import Showhy from '../HuiYuan/Showhy.vue';
const router=useRouter()
onMounted(()=>{
    show()
})
//该状态
const gai=(xx:any)=>{
 axios.get("https://localhost:7127/api/Dj/UpState",{params:{id:xx}}).then(res=>{
    if(res.data>0){
            alert("状态修改成功")
            show()
        }
        else{
            alert("状态修改失败")
        }
 })
}

const da=ref([{
    "dId": 0,
    "djName": "",
    "djState": null
  }])

  const show=()=>{
    axios.get("https://localhost:7127/api/Dj/GetAll").then(res=>{
        da.value=res.data
    })
  }

</script>

<style scoped>

</style>